<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="../js/vue.min.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <link type="text/css" rel="stylesheet" href="../css/bootstrap.min.css">
    <title>Document</title>
</head>

<body>
    <div class="container">
        <div id="app1">
            <button class="btn btn-default" @click="start">浪起来</button>
            <button class="btn btn-default" @click="stop">稳住</button> <br> {{message}}
        </div>
    </div>


    <script type="text/javascript">
        var app1 = new Vue({
            el: "#app1",
            data: {
                message: "hello world!",
                intervalId: null
            },
            methods: {
                start() {

                    if (this.intervalId != null)
                        return;

                    this.intervalId = setInterval(() => {
                        var start = this.message.substring(0, 1);
                        var end = this.message.substring(1);
                        this.message = end + start;
                    }, 400);

                },
                stop() {
                    clearInterval(this.intervalId);
                    this.intervalId = null;
                }
            }
        });
    </script>
</body>

</html>